<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .box{
            width: 200px;
            height: 200px;
            background-color: green;
            text-align: center;
            line-height: 200px;
            font-size: 50px;
        }
    </style>
</head>
<body>
    <div class="box">0</div>
    <script>
        var box=document.querySelector('.box');
        let count=0;
        function debounce(fun,wait){
            var timeout
            return function(){
            //    fun()
            //    console.log(this);
            var context=this;
            var args=arguments;
            // console.log(args);
             clearTimeout(timeout);
            timeout=setTimeout(function(){
                fun.apply(context,args);
            },wait);
            
            }
        }
        function getUserAction(e){
            box.innerText=++count;
        }
        box.addEventListener('mousemove',debounce(getUserAction,1000));
        
    </script>
</body>
</html>